from django.db import models


# 岗位表
class Gang(models.Model):
    name = models.CharField(max_length=120)
    money = models.IntegerField('价格')


# 员工表
class Staff(models.Model):
    username = models.CharField(max_length=20)
    password = models.CharField(max_length=120)
    # 所属领导表  领导也在这个员工表里 用自关联
    leader = models.ForeignKey("self", on_delete=models.SET_NULL, null=True)
    gang = models.ForeignKey(Gang, on_delete=models.SET_NULL, null=True)


# 业务量
class Business(models.Model):
    staff = models.ForeignKey(Staff, on_delete=models.SET_NULL, null=True)
    money = models.IntegerField('业务量')


# 薪水
class Salary(models.Model):
    username = models.CharField('姓名', max_length=20)
    gang = models.CharField('岗位', max_length=20)
    money = models.IntegerField('岗位工资')
    ticheng = models.IntegerField('提成')
    zhu_ticheng = models.IntegerField('主任提成', null=True)
    total = models.IntegerField('总额',default=0)
